const USER_INFO_KEY = 'ning_shopping_info'
const HISTORY_KEY = 'ning_history_list'

// 设置个人信息
export const setInfo = (object) => {
  localStorage.setItem(USER_INFO_KEY, JSON.stringify(object))
}

// 获取用户信息
export const getInfo = () => {
  const result = localStorage.getItem(USER_INFO_KEY)
  return result ? JSON.parse(result) : { userId: '', token: '' }
}

// 移除用户信息
export const removeInfo = () => {
  localStorage.removeItem(USER_INFO_KEY)
}

// 设置搜索历史
export const setHistoryList = (historyList) => {
  localStorage.setItem(HISTORY_KEY, JSON.stringify(historyList))
}

// 获取搜索历史信息
export const getHistoryList = () => {
  const result = localStorage.getItem(HISTORY_KEY)
  return result ? JSON.parse(result) : []
}

// 移除搜索历史信息
export const removeHistoryList = () => {
  localStorage.removeItem(HISTORY_KEY)
}
